package com.darwin.darwinGpuEngine.core {

    import com.darwin.darwinGpuEngine.utils.StatsObject;
    
    import flash.display3D.Context3D;

	/**
     * 一个场景可以包含很多GNode显示节点
	 * <br>虽然GScene中包含有x,y, rotation之类的属性，但建议不要通过这种方法来改变场景位置。
	 * <br>推荐用GScene的camera(摄影机)来推拉/旋转镜头来实现变换。
	 * @author Roland
	 * 
	 */
    public class GScene extends GNode {

        protected var camera:GCam;

        public var br:Number = 0.0;
        public var bg:Number = 0.0;
        public var bb:Number = 0.0;

        override public function get numTris():uint {
            return totalTris;
        }

        override public function get drawCalls():uint {
            return totalDrawCalls;
        }

        protected var totalTris:int = 0;
        protected var totalDrawCalls:int = 0;

        private var _backGroundColor:Number = 0x000000;

        public function get backGroundColor():Number {
            return _backGroundColor;
        }

		/**
		 *	场景背景色 
		 * @param value
		 * 
		 */
        public function set backGroundColor(value:Number):void {
            _backGroundColor = value;
            br = (backGroundColor >> 16) / 255.0;
            bg = (backGroundColor >> 8 & 255) / 255.0;
            bb = (backGroundColor & 255) / 255.0;
        }

		/**
		 * 实例化一个场景 
		 */
        public function GScene() {
            super();
            mouseEnabled = true;
        }

        internal function setCameraRef(value:GCam):void {
            camera = value;
        }

        override internal function drawNode(context:Context3D, camera:GCam, parentMatrixChanged:Boolean, statsObject:StatsObject):void {
			
			for each(var child:GNode in children) {
				child.drawNode(context, camera, false, statsObject);
			}
        }
    }
}